<template>
	<view class="content">
			<get-userinfo @userClick="showContent" v-if="isCause"> </get-userinfo>
			<view v-else>
				<view class="home_title">
						<view class="title">
							<view class="currentTitle">
									<uni-segmented-control :current="current" :values="items.map(v => v.title)" @clickItem="onClickItem" style-type="text" active-color="#d4237a"></uni-segmented-control>
							</view>
						</view>
						<view class="iconfont icon-search" @click="search"></view>
				</view>
				<view class="home_content">
				    <view v-if="current === 0">
						<home-recomment></home-recomment>
				    </view>
				    <view v-if="current === 1">
				       <home-new></home-new>
				    </view>
				    <view v-if="current === 2">
				       <home-category></home-category>
				    </view>
					<view v-if="current === 3">
						<home-abnum></home-abnum>
					</view>
				</view>
			</view>

	</view>
</template>

<script>
	//tab标签页组件
	import {uniSegmentedControl } from '@dcloudio/uni-ui'
	import  homeAbnum  from './home-abnum'
	import  homeCategory  from './home-category'
	import 	homeNew  from './home-new'
	import 	homeRecomment  from './home-recomment'
	import 	getUserinfo  from '../getUserinfo'
	export default {
		components:{
			homeAbnum,
			homeCategory,
			homeNew,
			homeRecomment,
			uniSegmentedControl,
			getUserinfo
		},
		data() {
			return {
			     items: [
					 {title:'推荐'},
					 {title:'最新'},
					 {title:'分类'},
					 {title:'专辑'},
					 ],
			     current: 0,
				 indexmsg:{},
				 isCause:true
			}
		},
		mounted() {
			let _this = this
			uni.getStorage({
				key:"userinfo",
				success(e) {
					_this.isCause = true
				},
				fail(e) {
					console.log(e)
				}
			})
		},
		methods: {
			onClickItem(e) {
			   if (this.current !== e.currentIndex) {
				   this.current = e.currentIndex;
				  
			   }
			},
			search(){
				uni.switchTab({ url: '/pages/search/index'});
			},
			showContent(e){
				this.isCause = e
				console.log(e)
			}
		}
	}
</script>

<style lang="scss" scoped>
.content{
	.home_title{
		.title{
			position: relative;
			.currentTitle{
				width:60%;
				margin: 0 auto;
			}
		}
		.icon-search{
			position: absolute;
			top:10px;
			right:6%;
		}
	}
	.home_content{
		
	}
}
	
</style>
